package leetcode;

import java.util.LinkedList;

public class LC2390 {

    public static String removeStars(String s) {
        LinkedList<Character> stack = new LinkedList<>();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '*') {
                stack.pop();
            } else stack.push(s.charAt(i));
        }
        String ans  = "";
        while (!stack.isEmpty()) {
            ans += stack.removeLast();
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(removeStars("lee**c*d"));
    }

}
